<?
class Crud_todo_model extends CI_model {

	function get_records()
	{
		$query = $this->db->query("SELECT * FROM crud_todo ORDER BY progress DESC");
		return $query->result();

	}

	function get_one_record($id)
		{
		$query = $this->db->query("SELECT * FROM crud_todo WHERE id='".$id."' ORDER BY id DESC");
		$row = $query->row();
		   		$data = array
				(
					'id' => $row->id,
					'titel' => $row->titel,
					'beskrivelse' => $row->beskrivelse,
					'prioritet' => $row->prioritet,
					'progress' => $row->progress,
					'filer' => $row->filer,


				);
			
				return $data;
				}


	function add_record($data)
	{
		$this->db->insert('crud_todo',$data);
		return;

	}


	function update_record($data, $id)
	{
		$this->db->where('id', $id);
		$this->db->update('crud_todo', $data);

	}

	function delete_record()
	{
		$this->db->where('id', $this->uri->segment(3));
		$this->db->delete('crud_todo');
		
	}



}
?>
